﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Isha.Infrastructure;

namespace Isha.Entities
{
    public class ContentItem
    {
        [Key]
        public int ContentItemID { get; set; }

        [Required]
        [StringLength(50)]
        public string Title { get; set; }

        [StringLength(1000)]
        public string Description { get; set; }

        [ForeignKey("ContentType")]
        [Required]
        public int ContentTypeID { get; set; }

        [StringLength(50)]
        public string View { get; set; }

        [StringLength(50)]
        public string Link { get; set; }

        [ForeignKey("Language")]
        public int? LanguageID { get; set; }

        public bool? IsPublished { get; set; }

        public DateTime? PublishStartDate { get; set; }

        public DateTime? PublishEndDate { get; set; }

        public bool? AllowComments { get; set; }

        public bool ExcludeNavigation { get; set; }

        public bool? CheckedIn { get; set; }

        [ForeignKey("ParentItem")]
        public int? ParentItemID { get; set; }

        public int DisplayOrder { get; set; }

        [StringLength(10)]
        public string CreatedBy { get; set; }

        public DateTime CreatedOn { get; set; }

        [StringLength(10)]
        public string ModifiedBy { get; set; }

        public DateTime? ModifiedOn { get; set; }

        string contentxml;

        [StringLength(4000)]
        public string ContentXml
        {
            get
            {
                return contentxml;
            }
            set
            {
                contentxml = value;
            }
        }

        [ScaffoldColumn(false)]
        public dynamic Content
        {
            get;
            set;
        }

        [ScaffoldColumn(false)]
        public bool IsHome { get; set; }

        [ScaffoldColumn(false)]
        public dynamic Type { get; set; }

        [ScaffoldColumn(false)]
        public bool IsContainable { get { return Content.IsContainable; } }

        public virtual ContentType ContentType { get; set; }

        public virtual Language Language { get; set; }

        public virtual ContentItem ParentItem { get; set; }

        public virtual ICollection<ContentItem> ContentItems { get; set; }

        public virtual ICollection<Comment> Comments { get; set; }
    }
}